var url="submit.php";
if (window.XMLHttpRequest)
{
xmlhttp=new window.XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
}

function newElement(NS, tag)
{
if (navigator.appName=="Microsoft Internet Explorer")
{
return document.createElement(tag);
}
else
{
return document.createElementNS(NS, tag);
}
}

function ajaxlogin()
{
var statestr=null;
var username=document.getElementById('username').value;
var password=document.getElementById('password').value;
var sendstring = 'action=login&uname='+username;
sendstring = sendstring+'&passwd=';
sendstring = sendstring+password;

var stateelement=newElement("http://www.w3.org/1999/xhtml", "div");
stateelement.setAttribute("id", "loginstate");
document.getElementById("topright").replaceChild(stateelement, document.getElementById('loginstate'));

if (username.length > 0 && password.length > 0)
{
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState==4)
{
statestr=document.createTextNode(xmlhttp.responseText);
document.getElementById("loginstate").appendChild(statestr);

if (xmlhttp.responseText.indexOf("Ingelogd")==!"-1")
{
if (window.location.pathname.indexOf('showstory.php')=="1")
{
window.location.reload();
}
document.getElementById('username').disabled=true;
document.getElementById('password').disabled=true;
document.getElementById('submit').disabled=true;
}
}
};

xmlhttp.open("POST", url, true);

xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

xmlhttp.send(sendstring);

return false;
}
else
{
statestr=document.createTextNode("Geen gebruikersnaam of wachtwoord ingevoerd.");
}
document.getElementById("loginstate").appendChild(statestr);
}

function pollsubmit(optid)
{
var statestr=null;
var polloption = document.getElementById(optid).value;
var pollid = document.getElementById('pollform').name;
var sendstring = 'action=pollvote&pollid='+pollid;
sendstring = sendstring+'&polloption=';
sendstring = sendstring+polloption;

xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState==4)
{
document.getElementById('polloption1').disabled=true;
document.getElementById('polloption2').disabled=true;
document.getElementById('polloption3').disabled=true;
document.getElementById('polloption4').disabled=true;
document.getElementById('polloption5').disabled=true;
document.getElementById('polloption6').disabled=true;
}
};

xmlhttp.open("POST", url, true);

xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

xmlhttp.send(sendstring);
}

function confirmation(id)
{
var confirma = confirm("Reactie verwijderen, weet u het zeker?");

if (confirma==true)
{
var sendstring = 'action=delcomment&id='+id;

xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState==4)
{
var comment = document.getElementById(id);

document.getElementById('comments').removeChild(comment);
}
};

xmlhttp.open("POST", url, true);

xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

xmlhttp.send(sendstring);
}
}

function resredir(){

var sendstring = 'action=ressubmit&res='+window.screen.width;

xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState==4)
{
window.location.reload();
}
};

xmlhttp.open("POST", url, true);

xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

xmlhttp.send(sendstring);
}